perf: Avoid unnecessary editor assets requests#126
Merged
Conversation
dcalhoun
commented
May 12, 2025
| * @typedef {Object} EditorAssetConfig | ||
| * | ||
| * @property {string[]} allowedBlockTypes Array of allowed block types provided by the API. | ||
| * @property {Object} wpDependencies WordPress dependencies, empty when allowedPackages is provided. |
Member
Author
There was a problem hiding this comment.
This was removed in a separate commit as its usage was removed entirely in an earlier commit.
The usage was removed in earlier commits.
We now utilize the `loadEditorAssets` utility twice--once to load i18n modules, again to load the remaining `@wordpress` modules. The second invocation occurs immediately after the first, and there is no benefit from making another network request.
30c0cec to
45a84bf
Compare
Member
Author
|
Rebased to exclude the now merged |
kean
approved these changes
May 13, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Rely upon a cache to avoid unnecessary network requests during editor initialization.
Why?
We invoke
loadEditorAssetstwice—once for i18n modules, and then again for all other@wordpressmodules. The second invocation is performed immediately after the first, and there is no benefit for requesting a new response.How?
Cache the API endpoint response in memory. Long-term, we plan to cache the response and the assets themselves, which is explored in #107.
Testing Instructions
_pluginsdebug flag enabled.Accessibility Testing Instructions
N/A, no user-facing changes.
Screenshots or screencast
N/A, no user-facing changes.